-- AUTOR................:LINX
-- FUNCAO.: ESSE SCRIPT CRIA AS SEGUINTES PROCEDURE:
--						    LX_CADE 
--						    LX_CADE_COLUNA

--XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-- CRIA LX_CADE
--XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[LX_CADE]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[LX_CADE]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE LX_CADE @TEXTO VARCHAR(100)=NULL AS
	IF SUBSTRING(@TEXTO,1,1) <> '%'
		SELECT @TEXTO = '%'+@TEXTO
	IF SUBSTRING(@TEXTO,DATALENGTH(@TEXTO),1) <> '%'
		SELECT @TEXTO = @TEXTO+'%'
	SELECT * FROM SYSOBJECTS WHERE NAME LIKE @TEXTO AND TYPE = 'U'

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


--XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-- CRIA LX_CADE_COLUNA
--XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[LX_CADE_COLUNA]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[LX_CADE_COLUNA]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE  PROCEDURE LX_CADE_COLUNA @TEXTO VARCHAR(100)=NULL AS
	IF SUBSTRING(@TEXTO,1,1) <> '%'
		SELECT @TEXTO = '%'+@TEXTO
	IF SUBSTRING(@TEXTO,DATALENGTH(@TEXTO),1) <> '%'
		SELECT @TEXTO = @TEXTO+'%'
	SELECT OBJECT_NAME(ID) TABELA,NAME COLUNA FROM SYSCOLUMNS WHERE NAME LIKE @TEXTO order by OBJECT_NAME(ID)


GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

